home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 426-450 / disk_438 / toollib / tool.doc < prev    next >
Text File  |  1992-05-06  |  41KB  |  1,143 lines

  1.  
  2.                        tool.library version 7.6
  3.                   © Copyright 1990 Jaba Development
  4.            written with the Devpac Assembler version 2.14 by
  5.                          Jan van den Baard
  6.  
  7.  
  8.  DISCLAIMER
  9.  ----------------------------------------------------------------------------
  10.  The author takes no responsibility as to the suitability or accuracy of this
  11.  documentation and/or the program(s) it desribes. Any damage sustained by the
  12.  use of  this documentation and/or  the program(s) it  describes is  the sole
  13.  responsibility of the user her/him self.
  14.  ----------------------------------------------------------------------------
  15.  
  16.  COPYRIGHT
  17.  ----------------------------------------------------------------------------
  18.  tool.library, © Copyright 1990-91 by Jaba Development. All rights reserved.
  19.  This program may be  distributed  non-commercially only  providing that the
  20.  source code, documentation and copyright notice remains intact. This program
  21.  is FREEWARE so no financial donation is neacecary (but welcome).
  22.  ----------------------------------------------------------------------------
  23.  
  24.  This is version 7.6 of a shared library containing 45 usefull functions  for
  25.  all kinds of programs.  The functions in this library are not of a  specific
  26.  kind but cover a lot of the Amiga faccilities. There are functions for ports
  27.  , sorting, gadgets, memory, string, directory and file handling. This manual
  28.  is devided into the following sections:
  29.  
  30.     THE ROUTINES                    I.
  31.     STRUCTURES AND DEFINITIONS      II.
  32.     THE FILEREQUESTER               III.
  33.     HISTORY                         IV.
  34.     NOTES                           V.
  35.  
  36.  ----------------------------------------------------------------------------
  37.                               I. THE ROUTINES
  38.  ----------------------------------------------------------------------------
  39.  NAME
  40.         Port = CreatePort( Name, Pri );
  41.          D0       -30       A0   D0
  42.  
  43.  FUNCTION
  44.         To allocate and set up a message port.
  45.  
  46.  INPUTS
  47.         Name - A pointer to a NULL terminated string representing the
  48.                name of the message port or NULL if the port should not
  49.                be globaly recognizable to other tasks.
  50.  
  51.         Pri  - A 32 bit integer representing the message port priority.
  52.  
  53.  RESULT
  54.         "Port" will be a pointer to the newly created message port or
  55.         NULL if an error occured.
  56.         NOTE: The message port is only added to the system port-list if
  57.               you specify a name for it. If you don't the port can not
  58.               be found by other tasks.
  59.  
  60.  NAME
  61.         DeletePort( Port );
  62.            -36       A0
  63.  
  64.  FUNCTION
  65.         To de-allocate and remove a message port.
  66.  
  67.  INPUTS
  68.         Port - A pointer to the message port that is to be deleted.
  69.  
  70.  RESULT
  71.         The message port is removed and de-allocated.
  72.  
  73.  NAME
  74.         IOReq = CreateExtIO( Port, Size );
  75.          D0        -42        A0    D0
  76.  
  77.  FUNCTION
  78.         To allocates and initialize an IORequest structure.
  79.  
  80.  INPUTS
  81.         Port - A pointer to the message port which is signaled if a message
  82.                is executed.
  83.  
  84.         Size - A 32 bit integer that represents the size if the IORequest
  85.                structure.
  86.  
  87.  RESULT
  88.         "IOReq" will be a pointer to the allocated and initialized IORequest
  89.         structure or NULL if an error occured.
  90.  
  91.  NAME
  92.         DeleteExtIO( IOReq );
  93.            -48        A0
  94.  
  95.  FUNCTION
  96.         To de-allocate an IORequest structure.
  97.  
  98.  INPUTS
  99.         IOReq - A pointer to the IORequest structure to be de-allocated.
  100.  
  101.  NAME
  102.         IOReq = CreateStdIO( Port );
  103.          D0        -54        A0
  104.  
  105.  FUNCTION
  106.         To allocate and initialize an IOStdReq structure.
  107.  
  108.  INPUTS
  109.         Port - A pointer to the message port which is signaled if a message
  110.                is executed.
  111.  
  112.  RESULT
  113.         "IOReq" will be a pointer to the allocated and initialized IOStdReq
  114.         structure or NULL if an error occured.
  115.  
  116.  NAME
  117.         DeleteStdIO( IOReq );
  118.            -60        A0
  119.  
  120.  FUNCTION
  121.         To de-allocate an IOStdReq structure.
  122.  
  123.  INPUTS
  124.         IOReq - A pointer to the IOStdReq structure to be de-allocated.
  125.  
  126.  NAME
  127.         timedelay = CreateTimeDelay(port,seconds,micros);
  128.             D0            -66        A0     D0     D1
  129.  
  130.  FUNCTION
  131.         Sets up the timer.device to be able to put a task to sleep for a
  132.         precise amount of time.
  133.  
  134.  INPUTS
  135.         port    - A pointer to a message port which, if this port was
  136.                   signaled, wakes up the task before the time ran out.
  137.                   This may also be NULL but that makes it impossible to
  138.                   stop the delay before the time runs out.
  139.  
  140.         seconds - A 32-bit integer representing the amount of seconds to
  141.                   put the task to sleep.
  142.  
  143.         micros  - A 32-bit integer representing the amount of micro-seconds
  144.                   to put the task to sleep.
  145.  
  146.  RESULT
  147.         timedelay - A pointer to a TimeDelay structure or NULL if an error
  148.                     occured.
  149.  
  150.  NAME
  151.         yourmsg = DoTimeDelay(timedelay);
  152.                      -72        A0
  153.  
  154.  FUNCTION
  155.         To put a task to sleep for a specific time.
  156.  
  157.  INPUTS
  158.         timdelay - A pointer to a TimeDelay structure as returned by
  159.                    "CreateTimeDelay".
  160.  
  161.  RESULT
  162.         "yourmsg" will be TRUE if the routine breaks off because it has
  163.         been signalled by the message port supplied by you and FALSE if
  164.         the time rran out.
  165.  
  166.  NAME
  167.         DeleteTimeDelay(timedelay);
  168.               -78          A0
  169.  
  170.  FUNCTION
  171.         To deallocate and erase the TimeDelay structure and close all of it's
  172.         resources.
  173.  
  174.  INPUTS
  175.         timdelay - A pointer to a TimeDelay structure as returned by
  176.                    "CreateTimeDelay".
  177.  
  178.  NAME
  179.         QuickSort( Base, Num, Size, Compar );
  180.            -84      A0   D0    D1     A1
  181.  
  182.  FUNCTION
  183.         To sort an array of elements.
  184.  
  185.  INPUTS
  186.         Base   - A pointer to the first element in the array.
  187.  
  188.         Num    - A 32 bit integer representing the number of elements in the
  189.                  array.
  190.  
  191.         Size   - A 32 bit integer representing the size of an element.
  192.                  NOTE: The size of an element may NOT be larger than 64
  193.                        KBytes.
  194.  
  195.         Compar - A pointer to a routine that does the comparrison between
  196.                  two elements. This is called like this:
  197.  
  198.                  Compar(a,b);
  199.  
  200.                  The arguments "a" and "b" are pushed on the stack before
  201.                  calling the routine. The routine must return a 32 bit
  202.                  integer. It should return -1, 0 or 1 depending on wether
  203.                  element "a" is to be considerd smaller, equal or bigger than
  204.                  element "b". The comparrison routine is passed POINTERS to
  205.                  the elements in the array.
  206.  
  207.  NAME
  208.         SwapMem( MemA, MemB, Size );
  209.           -90     A0    A1    D0
  210.  
  211.  FUNCTION
  212.         To exchange two areas of memory.
  213.  
  214.  INPUTS
  215.         MemA - A pointer to the first block of memory.
  216.  
  217.         MemB - A pointer to the second block of memory.
  218.  
  219.         Size - A 32 bit integer representing the size in bytes of the two
  220.                memory areas.
  221.  
  222.         NOTE: The memory areas swapped can NOT be larger than 64 KByte.
  223.  
  224.  NAME
  225.         Set = TestBits( Value, Bits );
  226.         D0       -96      D0    D1
  227.  
  228.  FUNCTION
  229.         To test wether or not certain bits are set in a value.
  230.  
  231.  INPUTS
  232.         Value - A 32 bit integer representing the value in which the bits
  233.                 are tested.
  234.  
  235.         Bits  - A 32 bit integer representing the bits to be tested.
  236.  
  237.  RESULT
  238.         Set will be TRUE if the bits where set in "Value" and FALSE if not.
  239.  
  240.  NAME
  241.         SelectGadget( Window, Gadget, Req );
  242.             -102        A0      A1    A2
  243.  
  244.  FUNCTION
  245.         To visually select a gadget. Also the SELECTED flag in the "Flags"
  246.         field of the gadget will be set.
  247.  
  248.  INPUTS
  249.         Window - A pointer to the window in which the gadget is located.
  250.  
  251.         Gadget - A pointer to the gadget which must be selected.
  252.                  NOTE: Only gadget of the "TOGGLESELECT" type will be
  253.                        selected.
  254.  
  255.         Req    - If the gadget is located in a requester you must put a
  256.                  pointer to that requester here. If no requester is used
  257.                  put NULL here.
  258.  
  259.  NAME
  260.         DeSelectGadget( Window, Gadget, Req );
  261.               -108        A0      A1    A2
  262.  
  263.  FUNCTION
  264.         To visually select a gadget. Also the SELECTED flag in the "Flags"
  265.         field of the gadget will be cleared.
  266.  
  267.  INPUTS
  268.         Window - A pointer to the window in which the gadget is located.
  269.  
  270.         Gadget - A pointer to the gadget which must be de-selected.
  271.                  NOTE: Only gadget of the "TOGGLESELECT" type will be
  272.                        de-selected.
  273.  
  274.         Req    - If the gadget is located in a requester you must put a
  275.                  pointer to that requester here. If no requester is used
  276.                  put NULL here.
  277.  
  278.  NAME
  279.         MutualExclude( Window, Gadget, From, Req );
  280.              -114        A0      A1     A2   A3
  281.  
  282.  FUNCTION
  283.         To mutually exclude gadgets if a certan gadget is selected.
  284.  
  285.  INPUTS
  286.         Window - A pointer to the window in which the gadgets are located.
  287.  
  288.         Gadget - A pointer to the gadget which does the MutualExcluding.
  289.                  The "MutualExclude" field of this gadget represents the
  290.                  gadgets to be mutually excluded. Every set bit represents
  291.                  a gadget that should be de-selected if this gadget is
  292.                  selected.
  293.  
  294.         From   - A pointer to the first gadget in a list from which the
  295.                  routine starts to look for gadgets to be de-selected.
  296.                  NOTE: Only gadgets of the "TOGGLESELECT" type will be
  297.                        mutually excluded.
  298.  
  299.         Req    - If the gadgets are located in a requester you must put a
  300.                  pointer to that requester here. If no requester is used
  301.                  put NULL here.
  302.  
  303.  NAME
  304.         MutualInclude( Window, Gadget, From, Req );
  305.              -120        A0      A1     A2   A3
  306.  
  307.  FUNCTION
  308.         To mutually include gadgets if a certan gadget is selected.
  309.  
  310.  INPUTS
  311.         Window - A pointer to the window in which the gadgets are located.
  312.  
  313.         Gadget - A pointer to the gadget which does the MutualIncluding.
  314.                  The "MutualExclude" field of this gadget represents the
  315.                  gadgets to be mutually included. Every set bit represents
  316.                  a gadget that should be selected if this gadget is
  317.                  selected.
  318.  
  319.         From   - A pointer to the first gadget in a list from which the
  320.                  routine starts to look for gadgets to be selected.
  321.                  NOTE: Only gadgets of the "TOGGLESELECT" type will be
  322.                        mutually included.
  323.  
  324.         Req    - If the gadgets are located in a requester you must put a
  325.                  pointer to that requester here. If no requester is used
  326.                  put NULL here.
  327.  
  328.  NAME
  329.         EraseGadget( Window, Gadget, Req );
  330.            -126        A0      A1    A2
  331.  
  332.  FUNCTION
  333.         To erase a gadget from the window or requester.
  334.  
  335.  INPUTS
  336.         Window - A pointer to the window in which the gadget is located.
  337.  
  338.         Gadget - A pointer to the gadget which must be erased.
  339.  
  340.         Req    - If the gadget is located in a requester you must put a
  341.                  pointer to that requester here. If no requester is used
  342.                  put NULL here.
  343.  
  344.  NAME
  345.         GadgetOn( Window, Gadget, Req );
  346.           -132      A0      A1    A2
  347.  
  348.  FUNCTION
  349.         To enable a gadget to be being clicked.
  350.         It's bassicly the same as Intuition's "OnGadget" only this
  351.         routine first erases the gadget from the display and then refreshes
  352.         only the gadget switched on.
  353.  
  354.  INPUTS
  355.         Window - A pointer to the window in which the gadget is located.
  356.  
  357.         Gadget - A pointer to the gadget which must be switched on.
  358.  
  359.         Req    - If the gadget is located in a requester you must put a
  360.                  pointer to that requester here. If no requester is used
  361.                  put NULL here.
  362.  
  363.  NAME
  364.         GadgetOff( Window, Gadget, Req );
  365.            -138      A0      A1    A2
  366.  
  367.  FUNCTION
  368.         To disable a gadget from being clicked.
  369.         It's bassicly the same as Intuition's "OffGadget" only this
  370.         routine first erases the gadget from the display and then refreshes
  371.         only the gadget switched off.
  372.  
  373.  INPUTS
  374.         Window - A pointer to the window in which the gadget is located.
  375.  
  376.         Gadget - A pointer to the gadget which must be switched off.
  377.  
  378.         Req    - If the gadget is located in a requester you must put a
  379.                  pointer to that requester here. If no requester is used
  380.                  put NULL here.
  381.  
  382.  NAME
  383.         sel = SelectTest( Gadget );
  384.         D0       -144       A0
  385.  
  386.  FUNCTION
  387.         To test if a gadget is selected or not.
  388.  
  389.  INPUTS
  390.         Gadget - A pointer to the gadget which is tested.
  391.  
  392.  RESULTS
  393.         "sel" will be TRUE if the gadget is selected and FALSE if not.
  394.  
  395.  NAME
  396.         ShadowGadget( Window, Gadget, Req, Color );
  397.             -150        A0      A1    A2    D0
  398.  
  399.  FUNCTION
  400.         To draw a shadow around the gadget in the specified color.
  401.  
  402.  INPUTS
  403.         Window - A pointer to the window in which the gadget is located.
  404.  
  405.         Gadget - A pointer to the gadget at which a shadow is drawed.
  406.  
  407.         Req    - If the gadget is located in a requester you must put a
  408.                  pointer to that requester here. If no requester is used
  409.                  put NULL here.
  410.  
  411.         Color  - A 32 bit integer representing the pen number in which the
  412.                  shadow is drawed.
  413.  
  414.  NAME
  415.         OnGList( Window, First, Req, Numgad );
  416.           -156     A0     A1    A2     D0
  417.  
  418.  FUNCTION
  419.         To switch a complete list of gadgets on.
  420.  
  421.  INPUTS
  422.         Window - See GadgetOn
  423.  
  424.         First  - A pointer to the first gadget in the list to be switched on.
  425.  
  426.         Req    - See GadgetOn
  427.  
  428.         NumGad - A 32 bit integer representing the number of gadgets to be
  429.                  switch on. If you put -1 here all the gadgets in the list
  430.                  are switched on.
  431.  
  432.  NAME
  433.         OffGList( Window, First, Req, Numgad );
  434.           -162      A0     A1    A2     D0
  435.  
  436.  FUNCTION
  437.         To switch a complete list of gadgets off.
  438.  
  439.  INPUTS
  440.         Window - See GadgetOff
  441.  
  442.         First  - A pointer to the first gadget in the list to be switched off.
  443.  
  444.         Req    - See GadgetOff
  445.  
  446.         NumGad - A 32 bit integer representing the number of gadgets to be
  447.                  switch off. If you put -1 here all the gadgets in the list
  448.                  are switched off.
  449.  
  450.  NAME
  451.         SelectGList( Window, First, Req, Numgad );
  452.            -168        A0     A1    A2     D0
  453.  
  454.  FUNCTION
  455.         To select a complete list of gadgets.
  456.  
  457.  INPUTS
  458.         Window - See SelectGadget
  459.  
  460.         First  - A pointer to the first gadget in the list to be selected.
  461.                  NOTE: Only gadget of the "TOGGLESELECT" type can be
  462.                        selected.
  463.  
  464.         Req    - See SelectGadget
  465.  
  466.         NumGad - A 32 bit integer representing the number of gadgets to be
  467.                  selected. If you put -1 here all the gadgets in the list
  468.                  are selected.
  469.  
  470.  NAME
  471.         DeSelectGList( Window, First, Req, Numgad );
  472.             -174         A0     A1    A2     D0
  473.  
  474.  FUNCTION
  475.         To de-select a complete list of gadgets.
  476.  
  477.  INPUTS
  478.         Window - See DeSelectGadget
  479.  
  480.         First  - A pointer to the first gadget in the list to be de-selected.
  481.                  NOTE: Only gadget of the "TOGGLESELECT" type can be
  482.                        de-selected.
  483.  
  484.         Req    - See DeSelectGadget
  485.  
  486.         NumGad - A 32 bit integer representing the number of gadgets to be
  487.                  de-selected. If you put -1 here all the gadgets in the list
  488.                  are de-selected.
  489.  
  490.  NAME
  491.         ShadowGList( Window, First, Req, Color, Numgad );
  492.             -180       A0     A1    A2    D0      D1
  493.  
  494.  FUNCTION
  495.         To draw shadows around a complete list of gadgets.
  496.  
  497.  INPUTS
  498.         Window - See ShadowGadget
  499.  
  500.         First  - A pointer to the first gadget in the list to be shadowed.
  501.  
  502.         Req    - See ShadowGadget
  503.  
  504.         Color  - See ShadowGadget
  505.         NumGad - A 32 bit integer representing the number of gadgets to be
  506.                  shadowed. If you put -1 here all the gadgets in the list
  507.                  are shadowed.
  508.  
  509.  NAME
  510.         EraseGList( Window, First, Req, Numgad );
  511.             -186       A0     A1    A2    D0
  512.  
  513.  FUNCTION
  514.         To erase a complete list of gadgets from a window or a requester.
  515.  
  516.  INPUTS
  517.         Window - See EraseGadget
  518.  
  519.         First  - A pointer to the first gadget in the list to be erased.
  520.  
  521.         Req    - See EraseGadget
  522.  
  523.         NumGad - A 32 bit integer representing the number of gadgets to be
  524.                  erased. If you put -1 here all the gadgets in the list
  525.                  are erased.
  526.  
  527.  NAME
  528.         InitMemoryChain(chain,size)
  529.               -192       A0    D0
  530.  
  531.  FUNCTION
  532.         To initialize a MemoryChain structure for use.
  533.  
  534.  INPUTS
  535.         chain - A pointer to a MemoryChain structure.
  536.  
  537.         size  - A 32-bit integer representing the size of a MemoryBlock.
  538.  
  539.  NAME
  540.         memptr = AllocItem(chain,size,reqs);
  541.           D0       -198      A0   D0   D1
  542.  
  543.  FUNCTION
  544.         To allocate a chunk of memory in a MemoryChain.
  545.  
  546.  INPUTS
  547.         chain - A pointer to the MemoryChain in which the memory will be
  548.                 allocated.
  549.  
  550.         size  - A 32-bit integer representing the size of the memory.
  551.  
  552.         reqs  - A 32-bit integer representing the memory requirements
  553.                 of the allocation.
  554.  
  555.         NOTE: The size is always rounded up to the nearest multiple of 8.
  556.  
  557.  RESULT
  558.         memptr - A pointer to the allocated memory or NULL if the allocation
  559.                  failed.
  560.         NOTE: The memory is always allocated in a longword boundary.
  561.  
  562.  NAME
  563.         FreeItem(chain,memptr,size)
  564.           -204     A0    A1    D0
  565.  
  566.  FUNCTION
  567.         To deallocate a chunk of memory allocated with AllocItem from a
  568.         MemoryChain.
  569.  
  570.  INPUTS
  571.         chain  - A pointer to the MemoryChain in which the memory was
  572.                  allocated.
  573.  
  574.         memptr - A pointer to the memory.
  575.  
  576.         size   - A 32 bit integer representing the size to be freed.
  577.  
  578.  NAME
  579.         FreeMemoryChain(chain)
  580.              -210        A0
  581.  
  582.  FUNCTION
  583.         To deallocate and re-initialize a complete MemoryChain.
  584.  
  585.  INPUTS
  586.         chain - A pointer to the MemoryChain
  587.  
  588.  RESULT
  589.         All memory allocated for the MemoryChain is deallocated and the
  590.         MemoryChain structure itself is re-initialized so that it can
  591.         be used again.
  592.  
  593.  NAME
  594.         Format( Buffer, FString, Args );
  595.         -216      A0      A1      A2
  596.  
  597.  FUNCTION
  598.         To format an output into a specified buffer.
  599.  
  600.  INPUTS
  601.         Buffer  - A pointer to a buffer in which the formatted output is
  602.                   copied. NOTE: You must make sure that the buffer is big
  603.                   enough to hold the formatted output.
  604.  
  605.         FString - A pointer to a NULL terminated string explaning how to
  606.                   interpred the arguments. The following format specifiers
  607.                   are supported:
  608.  
  609.                     %lc - the next long word in the argument array is
  610.                           formatted as a 8 bit character.
  611.  
  612.                     %ld - the next long word in the argument array is
  613.                           formatted as a 32 bit decimal number.
  614.  
  615.                     %lx - the next long word in the argument array is
  616.                           formatted as a 32 bit hexadecimal number.
  617.  
  618.                     %ls - the next long word in the argument array is
  619.                           formatted as a pointer to a NULL terminated
  620.                           string.
  621.  
  622.                   The "l" in these format specifiers is only neacecary
  623.                   when the arguments are 32 bit. Following this "l" sign
  624.                   you may also specify the following:
  625.  
  626.                   -> An optional minus sign to tell the routine to left
  627.                      justify the next formatted item within the field
  628.                      width
  629.  
  630.                   -> An optional digit string to tell the routine to fill
  631.                      out the formatted item with spaces. If the digit string
  632.                      is preceded with a "0" character the item will be
  633.                      filled out with "0" characters instead of spaces.
  634.  
  635.                   -> An optional period sign to seperate the field width
  636.                      specifier from the maximum characters specifier.
  637.  
  638.                   -> An optional digit string (for %ls and %s only) to tell
  639.                      the routine the maximum amount of characters to format
  640.                      from the string.
  641.  
  642.                   This routine is based on Exec's function "RawDoFmt()" which
  643.                   does NOT support any form of floating point formatting.
  644.                   If you have to format floating point numbers you will have
  645.                   to use "sprintf" from the standard C library.
  646.  
  647.         Args    - A pointer to an array in which the arguments are stored.
  648.                   NOTE: C programmers must link with "tool.lib" to get the
  649.                         arguments passed correctly to the routine.
  650.  
  651.  NAME
  652.         num = WriteFormat( Handle, FString, Args );
  653.         D0       -222        A0       A1     A2
  654.  
  655.  FUNCTION
  656.         To format an output and writes the result directly to a file.
  657.  
  658.  INPUTS
  659.         Handle  - A pointer to an AmigaDOS filehandle to which the formatted
  660.                   result will be written.
  661.  
  662.         FString - A pointer to a NULL terminated format string which can
  663.                   hold the same format specifiers as the format string from
  664.                   "Format". NOTE: The formatted output may NOT be larger
  665.                   that 512 bytes (including the terminating 0 byte.).
  666.  
  667.         Args    - A pointer to an array in which the arguments are stored.
  668.                   NOTE: C programmers must link witch "tool.lib" to get the
  669.                         arguments passed correctly to the routine.
  670.  
  671.  RESULT
  672.         "num" will read the exact amount of characters written to the file or
  673.         -1 if an error occured.
  674.  
  675.  NAME
  676.         match = MatchPattern( String, Pattern, Case );
  677.          D0        -228         A0      A1      D0
  678.  
  679.  FUNCTION
  680.         To perform a Unix style pattern match on a string.
  681.  
  682.  INPUTS
  683.         String  - A pointer to a NULL terminated string which will be matched
  684.                   with the pattern.
  685.  
  686.         Pattern - A pointer to a NULL terminated string which represents
  687.                   the pattern to be matched. The pattern may have the
  688.                   following wildcards:
  689.  
  690.                     "*" - representing any number of characters.
  691.                     "?" - representing a single character.
  692.  
  693.         Case    - A 32 bit boolean value which must be "CASE" if the routine
  694.                   should also check the character case and "NO_CASE" if not.
  695.  
  696.  RESULT
  697.         "match" will read TRUE if the string matched the pattern and FALSE
  698.         if not.
  699.  
  700.  NAME
  701.         pat = Isolate( Path, Buffer );
  702.         D0     -234     A0     A1
  703.  
  704.  FUNCTION
  705.         To scan a full pathname for a wildcard expansion and copy it, if
  706.         found, into a buffer.
  707.  
  708.  INPUTS
  709.         Path   - A pointer to a NULL terminated full AmigaDOS pathname.
  710.                  If a pattern was found at the end of the pathname this
  711.                  pattern will be copied into the buffer and the pathname
  712.                  will be truncated at the point where the pattern was found.
  713.                  NOTE: This routine only isolates patterns which has atleast
  714.                        one wildcard in it.
  715.  
  716.         Buffer - A pointer to a buffer in which the pattern, if found, is
  717.                  copied.
  718.  
  719.  RESULT
  720.         "pat" will be TRUE if a pattern was found and FALSE if not.
  721.  
  722.  NAME
  723.         BstrToCstr( Bstr, Buffer );
  724.            -240      A0     A1
  725.  
  726.  FUNCTION
  727.         To convert a BSTR string into a standard NULL terminated string.
  728.  
  729.  INPUTS
  730.         Bstr   - A BPTR to a BSTR string.
  731.  
  732.         Buffer - A buffer in which the string is copied.
  733.  
  734.  NAME
  735.         return = GetDate( DateStamp, Buffer, How);
  736.           D0      -246       A0        A1     D0
  737.  
  738.  FUNCTION
  739.         To convert a "DateStamp" structure into an ASCII string.
  740.  
  741.  INPUTS
  742.         DateStamp - A pointer to an initialized DateStamp structure
  743.                     or NULL for the current System time.
  744.  
  745.         Buffer    - A pointer to a buffer witch can hold atleast "MINDATE"
  746.                     bytes.
  747.  
  748.         How       - A 32 bit integer explaning what to convert.
  749.                     For example lets say that it is thursday 20 september
  750.                     1990 and it's 13:30:00 hour.
  751.  
  752.                     The result after a call to GetDate will be:
  753.                     ALL        - Thursday 20-09-1990 13:30:00
  754.                     ONLY_DAY   - Thursday
  755.                     ONLY_DATE  - 20-09-1990
  756.                     ONLY_TIME  - 13:30:00
  757.  
  758.  RESULTS
  759.         return will be TRUE if the conversion succeeded or FALSE if it failed
  760.         "Buffer" contains the converted ASCII form of "DateStamp" or the
  761.         System time.
  762.  
  763.  NAME
  764.         succes = OpenDir(directory,name);
  765.           D0      -252      A0      A1
  766.  
  767.  FUNCTION
  768.         To open a directory.
  769.  
  770.  INPUTS
  771.         directory - A pointer to a Directory structure.
  772.  
  773.         name      - A pointer to a NULL terminated string representing the
  774.                     name of the directory.
  775.  
  776.  RESULT
  777.         success - this reads TRUE if the directory opens succesfully and
  778.                   FALSE if an error occured.
  779.  
  780.  NAME
  781.         entry = GetEntry(directory);
  782.          D0       -258      A0
  783.  
  784.  FUNCTION
  785.         To read the next entry of the directory into memory.
  786.  
  787.  INPUTS
  788.         directory - A pointer to the Directory structure.
  789.  
  790.  RESULT
  791.         entry - this will be a pointer to an EntryInfo structure or NULL.
  792.                 If NULL is returned this could mean that an error occured.
  793.                 A call to IoErr should read ERROR_NO_MORE_ENTRIES otherwise
  794.                 an error has occured.
  795.                 NOTE: The directory is automaticaly UnLocked when the last
  796.                       entry was read.
  797.  
  798.  NAME
  799.         CloseDir(directory)
  800.           -264      A0
  801.  
  802.  FUNCTION
  803.         To UnLock the directory.
  804.  
  805.  INPUTS
  806.         directory - A pointer to the directory structure.
  807.  
  808.  NAME
  809.         FreeDirectory(directory);
  810.             -270         A0
  811.  
  812.  FUNCTION
  813.         To deallocate the memory a directory takes up.
  814.  
  815.  INPUTS
  816.         directory - A pointer to the directory structure.
  817.  
  818.  NAME
  819.         string = IoErrToStr()
  820.           D0       -276
  821.  
  822.  FUNCTION
  823.         To convert a DOS error into an ASCII form.
  824.  
  825.  RESULTS
  826.         string - this will be a pointer to a string representing the ASCII
  827.                  form of a DOS error or NULL if IoErr returned an unknown
  828.                  code.
  829.  
  830.  NAME
  831.         Freq = AllocFreq();
  832.          D0      -282
  833.  
  834.  FUNCTION
  835.         To allocate and initialize a FileRequester structure.
  836.  
  837.  RESULT
  838.         Freq - this will be a pointer to an allocated and initialized
  839.         FileRequester structure or NULL if the Allocation failed.
  840.  
  841.  NAME
  842.         FreeFreq( Freq );
  843.           -288     A0
  844.  
  845.  FUNCTION
  846.         To de-allocate a filerequester structure.
  847.  
  848.  INPUTS
  849.         Freq - A pointer to the FileRequester structure you want
  850.                de-allocated.
  851.  
  852.  NAME
  853.         error = FileRequest( Freq );
  854.                    -294       A0
  855.  
  856.  FUNCTION
  857.         To put up the filerequester.
  858.  
  859.  INPUTS
  860.         Freq - A pointer to an allocated and initialized FileRequester
  861.                structure.
  862.  
  863.  RESULT
  864.         error - this will be an error code explained in "THE FILEREQUESTER"
  865.         chapter of this documentation.
  866.  
  867.  ----------------------------------------------------------------------------
  868.                        II. STRUCTURES AND DEFINITIONS
  869.  ----------------------------------------------------------------------------
  870.  A pointer to the ToolBase structure is returned uppon a successfull call to
  871.  OpenLibrary().
  872.  
  873.  struct ToolBase
  874.  {
  875.   struct Library        LibNode;        The actual library structure.
  876.   struct ExecBase      *SysBase;        A pointer to ExecBase.
  877.   struct DosLibrary    *DOSBase;        A pointer to DOSBase.
  878.   struct IntuitionBase *IntuitionBase;  A pointer to IntuitionBase.
  879.   struct GfxBase       *GfxBase;        A pointer to GfxBase.
  880.   LONG                  SegList;        A BPTR to the library code.
  881.  };
  882.  
  883.  The library-base pointers in this structure can be used by a program to call
  884.  uppon functions of any of those libraries.
  885.  
  886.  A pointer to the TimeDelay structure is returned uppon a successfull call to
  887.  CreateTimeDelay().
  888.  
  889.  struct TimeDelay
  890.  {
  891.   struct MsgPort     *td_UserPort;     A pointer to your message port.
  892.   struct MsgPort     *td_ReplyPort;    Used by the timer.device.
  893.   struct timerequest *td_TimeRequest;  To specify the delay
  894.  };
  895.  
  896.  
  897.  The MemoryBlock, MemoryItem, BlockList and ItemList structures are used
  898.  internaly to hold all allocations together in a MemoryChain structure.
  899.  
  900.  struct MemoryChain
  901.  {
  902.   struct BlockList  mc_Blocks;        The list of blocks in the chain.
  903.   struct ItemList   mc_Items;         The list of items in the chain.
  904.   ULONG             mc_BlockSize;     The size of a block.
  905.  };
  906.  
  907.  The Directory structure is used to hold the entries of a directory
  908.  together.
  909.  
  910.  struct Directory
  911.  {
  912.   struct EntryInfo     *dr_First;       The first entry in the directory.
  913.   struct EntryInfo     *dr_End;         Always NULL.
  914.   struct EntryInfo     *dr_Last;        The last entry in the directory.
  915.   struct FileInfoBlock *dr_InfoBlock;   Used to read the entries.
  916.   BPTR                  dr_Lock;        Used to read the entries.
  917.   ULONG                 dr_NumEntries;  The number of entries in the dir.
  918.   struct MemoryChain    dr_DirMem;      The memory used up.
  919.  };
  920.  
  921.  The EntryInfo structure describes the entry.
  922.  
  923.  struct EntryInfo
  924.  {
  925.   struct EntryInfo  *ei_Next;           The next entry.
  926.   struct EntryInfo  *ei_Previous;       The previous entry.
  927.   USHORT             ei_Type;           The type of entry (see below)
  928.   UBYTE              ei_Name[32];       The entry name.
  929.   LONG               ei_SizeBytes;      The size in bytes (only with files)
  930.   LONG               ei_SizeBlocks;     The size in blocks (only with files)
  931.   LONG               ei_ProtectionBits; The protection bits
  932.   struct DateStamp   ei_Date;           The entry date (not for devices)
  933.  };
  934.  
  935.  The TOOL_VERSION and TOOL_REVISION defines represent the version and
  936.  revision number of the tool.library.
  937.  
  938.  The LONGALLIGN macro is used by the library memory routines to make the
  939.  size of the allocation even to a 8 byte boundary.
  940.  
  941.  The ITEM_FREE and ITEM_USED defines are used internaly by the library
  942.  memory routines to mark a MemoryItem as used or free.
  943.  
  944.  MINDATE   is a constant that represents the largest possible output of
  945.            GetDate().
  946.  ALL       tells GetDate to convert the complete date.
  947.  ONLY_DAY  tells GetDate only to convert the day of the week.
  948.  ONLY_DATE tells GetDate only to convert the date.
  949.  ONLY_TIME tells GetDate only to convert the time.
  950.  
  951.  NO_CASE   tells MatchPattern to check the characte case also.
  952.  CASE      tells MatchPattern not to check the character case.
  953.  
  954.  ENTRY_FILE  the entry is a file.
  955.  ENTRY_DIR   the entry is a directory.
  956.  ENTRY_DEV   the entry is a device. (only used by the FileRequester)
  957.  
  958.  DIRBLOCK    The size of a MemoryBlock in a directory.
  959.  
  960.  ----------------------------------------------------------------------------
  961.                           III. THE FILEREQUESTER
  962.  ----------------------------------------------------------------------------
  963.  Before  you  can call the  FileRequester you must first  call "AllocFreq" to
  964.  allocate and initialize a FileRequester structure and it's buffers.   If the
  965.  allocation  succeeded you will  be returned a  pointer to the following data
  966.  structure:
  967.  
  968.             struct FileRequester
  969.             {
  970.                 char             *fr_HeadLine;
  971.                 char             *fr_FileName;
  972.                 char             *fr_DirName;
  973.                 char             *fr_DontShow;
  974.                 USHORT            fr_LeftEdge;
  975.                 USHORT            fr_TopEdge;
  976.                 struct Window    *fr_Caller;
  977.                 struct Screen    *fr_Screen;
  978.                 struct Directory *fr_Directory;
  979.                 USHORT            fr_Flags;
  980.                 USHORT            fr_Colors[4];
  981.                 BPTR              fr_Handle;
  982.                 LONG              fr_Reserved;
  983.             };
  984.  
  985.  The  "fr_HeadLine"  field points to a buffer in which you can copy the title
  986.  of the FileRequester window with a maximum of 28 bytes.
  987.  
  988.  The "fr_FileName" field points to a buffer in which you can copy the default
  989.  filename. A maximum  of 32 bytes is allowed here. After the FileRequester is
  990.  closed  the last  selected filename can be found in this buffer.
  991.  
  992.  The "fr_DirName"  field points to a buffer in which you can copy the default
  993.  pathname with or without a wildcard expansion.  A maximum  of 256  bytes  is
  994.  allowed here. After the FileRequester is closed  the last  selected pathname
  995.  can be found in this buffer.
  996.  
  997.  The "fr_DontShow" filed points to a buffer in which you can copy  a wildcard
  998.  pattern which tells the FileRequester NOT to list the FILES which match this
  999.  pattern. A maximum of 32 bytes is allowed here.
  1000.  
  1001.  With "fr_LeftEdge" and "fr_TopEdge"  fields you can specify the  coordinates
  1002.  of the TopLeft corner of the FileRequester window on your screen. You should
  1003.  calculate  the position  so that  the FileRequester will fit on your screen.
  1004.  Using incorrect values will result in a "FREQ_CANT_OPEN" when  "FileRequest"
  1005.  is called. You can use the  "FREQ_WIDTH" and  "FREQ_HEIGHT" constants  which
  1006.  specify the FileRequester window width and height to calculate a position on
  1007.  your screen. The default settings are fr_LeftEdge = 10, fr_TopEdge = 15.
  1008.  
  1009.  In the "fr_Caller"  field you can put a pointer to a  window which calls the
  1010.  FileRequester.  If this field  is  initialized the  FileRequester will put a
  1011.  very small requester  in the  TopLeft corner  of this window  to disable the
  1012.  window  from receiving  IDCMP messages  while the FileRequester is still up.
  1013.  The requester is removed when the FileRequester is closed.  By default  this
  1014.  field is set to NULL.
  1015.  
  1016.  When you want the  FileRequester to  open on a  custom screen you must put a
  1017.  pointer to that screen in the "fr_Screen" field. This field defaults to NULL
  1018.  which tells the FileRequester to use the WorkBench screen.
  1019.  
  1020.  The "fr_Directory" field  points to a Directory structure  which is  already
  1021.  allocated and initialized by "AllocFreq" in which  the FileRequester  stores
  1022.  the directories it reads. This may also hold the last directory read  by the
  1023.  FileRequester even after the  FileRequester closed  depending  on wether the
  1024.  "FR_NoPreserve" bit was set or not. (see below).
  1025.  
  1026.  The "fr_Flags" field is used to switch certan functions in the FileRequester
  1027.  on or off. See below for an explanation of the possible flags. This defaults
  1028.  to "FR_ReturnVoid".
  1029.  
  1030.  The "fr_Colors[4]" fields can be used to define your own colors depending on
  1031.  wether the "FR_CustColor" flags is set or not. (see below).
  1032.  
  1033.  The "fr_Handle"  field is used  to return a  FileHandle to you is requested.
  1034.  (see below).
  1035.  
  1036.  Always set the "fr_Reserved" field to NULL because this field might  be used
  1037.  future version of the FileRequester/library.
  1038.  
  1039.  THE POSSIBLE FLAGS
  1040.  
  1041.  FR_NoPreserve
  1042.                   Normaly when the FileRequester is closed the directory last
  1043.                   read will  be  kept in  the  "fr_Directory"  field  of  the
  1044.                   FileRequester  structure.  This has the advatage that, when
  1045.                   the FileRequester is recalled, the directory  does not have
  1046.                   to be read all over again. This  also has  the disadvantage
  1047.                   that  the directory  will take  up atleast  5 KByte of your
  1048.                   memory.
  1049.  
  1050.  FR_NoDevs
  1051.                   Setting this flag  disables the FileRequester  from reading
  1052.                   and showing the mounted disk devices.
  1053.  
  1054.  FR_NoSort
  1055.                   Setting this flag  disables the FileRequester  from sorting
  1056.                   the entries of a directory by sort and alphabetically.
  1057.  
  1058.  FR_CustColor
  1059.                   If this flag is set the  FileRequester will  set the colors
  1060.                   defined in the  "fr_Colors[4]" fields  of the FileRequester
  1061.                   onto the screen it  appears on saving  the previous colors.
  1062.                   When the FileRequester is closed the old colors are reset.
  1063.  
  1064.  FR_ReturnOld
  1065.                   Setting this flag tell's the  FileRequester to try  to open
  1066.                   the selected file if the user closed the requester with OK.
  1067.                   The file will be opened using  MODE_OLDFILE  and the handle
  1068.                   is  put  in  the  "fr_Handle"  field  of  the FileRequester
  1069.                   structure.
  1070.  
  1071.  FR_ReturnNew
  1072.                   Setting this flag tell's the  FileRequester to try  to open
  1073.                   the selected file if the user closed the requester with OK.
  1074.                   The file will be opened using  MODE_NEWFILE  and the handle
  1075.                   is  put  in  the  "fr_Handle"  field  of  the FileRequester
  1076.                   structure.
  1077.  
  1078.  FR_ReturnReadWrite
  1079.                   Setting this flag tell's the  FileRequester to try  to open
  1080.                   the selected file if the user closed the requester with OK.
  1081.                   The file will be opened using MODE_READWRITE and the handle
  1082.                   is  put  in  the  "fr_Handle"  field  of  the FileRequester
  1083.                   structure.
  1084.  
  1085.  FR_ReturnVoid
  1086.                   This specifies NOT to open the selected file. default.
  1087.  
  1088.  
  1089.  POSSIBLE FILEREQUESTER RETURN CODES
  1090.  
  1091.  FREQ_OK         -> Everything OK. A  file  was  selected and,  if requested,
  1092.                     opened.
  1093.  
  1094.  FREQ_CANT_OPEN  -> The FileRequester could not be opened.  This  could  mean
  1095.                     that  not   enough  memory  was  available  or  that  the
  1096.                     "fr_LeftEdge" and/or "fr_TopEdge" fields contains invalid
  1097.                     values.
  1098.  
  1099.  FREQ_FILE_ERROR -> This means that the selected file failed to open.
  1100.  
  1101.  FREQ_CANCELED   -> This means that the user selected CANCEL or CLOSEWINDOW.
  1102.  
  1103.  ----------------------------------------------------------------------------
  1104.                                  IV. HISTORY
  1105.  ----------------------------------------------------------------------------
  1106.  
  1107.     VERION  7.1     -> Not Released.
  1108.  
  1109.     VERSION 7.2     -> The FileRequester now waits until the user selected
  1110.                        a gadget outside the file-selection area before it
  1111.                        starts to sort the entries.
  1112.  
  1113.     VERSION 7.3     -> "MatchPattern" had a bug resulting in the matching
  1114.                        always being case sensitive. This is now fixed.
  1115.  
  1116.     VERSION 7.4     -> I have put a pointer to the FileRequester window in
  1117.                        the "pr_WindowPtr" field of the Process structure
  1118.                        which results in the system requester appearing on
  1119.                        the same screen as the FileRequester. Also the
  1120.                        "DisplayBeep" function is called if a DOS error
  1121.                        occured.
  1122.  
  1123.     VERSION 7.5     -> When the "fr_NoPreserve" is not set and the
  1124.                        FileRequester is called the old directory is
  1125.                        displayed. When the directory had changed this
  1126.                        is not shown in the list. Now you can press the
  1127.                        "HELP" key and the directory is re-read.
  1128.  
  1129.     VERSION 7.6     -> MAJOR BUG FOUND !! I did forget to call "Permit()"
  1130.                        after a call to "Forbid()" in the ReadDevs routine
  1131.                        of the FileRequester what resulted in some very
  1132.                        strange situations. This is now fixed (phew!).
  1133.  
  1134.  ----------------------------------------------------------------------------
  1135.                                  V. NOTES
  1136.  ----------------------------------------------------------------------------
  1137.  Bug reports and suggestions (please !) too me at the following address:
  1138.  
  1139.                                                 Jan van den Baard
  1140.                                                 Bakkerstraat 176
  1141.                                                 3082 HE Rotterdam
  1142.                                                 Holland
  1143.